//
//  SHCCRNet.m
//  JiFengDaRen
//
//  Created by SH_iOS on 2017/12/5.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//


//修改代还信用卡信息
#define  KCCR_UPLOAD_BANK_INFO @"/data/api/upload_bank_info"

#import "SHCCRNet.h"


@implementation SHCCRNet

#pragma mark -- 修改银行卡
+ (void)putCreditBankCardInfoBankCardCode:(NSString *)bankCardCode
                                    phone:(NSString *)phone
                            repaymentDate:(NSString *)repaymentDate
                                 billDate:(NSString *)billDate
                                  expDate:(NSString *)expDate
                                     cvn2:(NSString *)cvn2
                             bankCardType:(int)bankCardType
                             usingChoices:(int)usingChoices
                                  success:(void (^)(id result))success
                              complection:(void(^)(id result))complection      failure:(void(^)(id erro))failure{
    
    NSDictionary *params =
        @{
          @"bank_card_code":bankCardCode,
          @"phone":phone,
          @"repayment_date":repaymentDate,
          @"bill_date":billDate,
          @"exp_date":expDate,
          @"cvn2":cvn2,
          @"bank_card_type":@(bankCardType),
          @"using_choices":@(usingChoices)
      
      };
    
    [MBProgressHUD showHUDAddedTo:[SHHelper currentViewController].view animated:YES];

    [MyDataService requestAFURL:KCCR_UPLOAD_BANK_INFO httpMethod:@"POST" params:params data:nil complection:^(id result) {
        SHLog(@"修改银行卡%@",result);
        [MBProgressHUD hideHUDForView:[SHHelper currentViewController].view  animated:YES];
        BOOL successed = [result[@"success"] boolValue];
        if (successed) {
            [[SHHelper currentViewController].view makeToast:@"提交成功！" duration:2.f position:@"center"];
            
            success(result);
        }else{
            complection(result[@"data"]);
            [[SHHelper currentViewController].view makeToast:result[@"data"] duration:2.f position:@"center"];
        }
        
        
    } failure:^(id erro) {
        [MBProgressHUD hideHUDForView:[SHHelper currentViewController].view  animated:YES];

        failure(erro);
        
    }];

}


+ (void)putCreditBankCardInfoBankCardCode:(NSString *)bankCardCode bankCardFrontPic:(NSString *)bankCardFrontPic
                        personPhoto:(NSString *)personPhoto
                                  success:(void (^)(id result))success
                              complection:(void(^)(id result))complection      failure:(void(^)(id erro))failure{
    
    NSDictionary *params =
    @{
      @"bank_card_code":bankCardCode,
      @"bank_card_front_pic":bankCardFrontPic,
      @"person_photo":personPhoto,

      };
    
    [MBProgressHUD showHUDAddedTo:[SHHelper currentViewController].view animated:YES];
    
    [MyDataService requestAFURL:KCCR_UPLOAD_BANK_INFO httpMethod:@"POST" params:params data:nil complection:^(id result) {
        SHLog(@"修改银行卡%@",result);
        [MBProgressHUD hideHUDForView:[SHHelper currentViewController].view  animated:YES];
        BOOL successed = [result[@"success"] boolValue];
        if (successed) {
            [[SHHelper currentViewController].view makeToast:@"提交成功！" duration:2.f position:@"center"];
            
            success(result);
        }else{
            complection(result[@"data"]);
            [[SHHelper currentViewController].view makeToast:result[@"data"] duration:2.f position:@"center"];
        }
        
        
    } failure:^(id erro) {
        [MBProgressHUD hideHUDForView:[SHHelper currentViewController].view  animated:YES];
        
        failure(erro);
        
    }];
    
}

@end
